package com.meituan.controller;

import com.meituan.pojo.resp.BaseResp;
import com.meituan.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
public class BaseController {

    @Autowired
    UploadUtils uploadUtils;

    @PostMapping("/upload")
    public BaseResp upload(@RequestParam("file") MultipartFile multipartFile){
        String upload = uploadUtils.upload(multipartFile);
        System.out.println(upload);
        if (StringUtils.isEmpty(upload)){
            return new BaseResp().ERROR();
        }
        return new BaseResp(1,"success",upload);
    }
}
